<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>${msg}</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all" />
    <!--公用样式-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/common/css/comment.css">
    <!--页面样式-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/common/css/style.css">
    <link rel="stylesheet" href="${re.contextPath}/plugin/common/css/extended.css">
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
</head>

<style>
    .layui-form-select dl dd.layui-this {
        background-color: #5775EF;
    }

    .layui-form-select dl dd.layui-select-tips {

    }
</style>

<body >

<!--头部-->
<header class="whitebg">
    <img src="${re.contextPath}/plugin/common/images/2@2x.png" class="logo" alt=""/>
</header>
<!--容器-->
<div class="container">
    <!--占位-->
    <div class="headerHight"></div>
    <!--注册需方企业账号-->
    <form action="" class="layui-form">
        <div class="regBox regBoxOne whitebg">
            <div class="ft22">${msg}</div>
            <ul class="clearfix">
                <li class="clearfix">
                    <label><span class="red">*</span> 用户名</label>
                    <input type="text" name="username" id="username" lay-verify="username"   placeholder="请输入用户名">
                </li>
                <li class="clearfix">
                    <label><span class="red">*</span> 真实姓名</label>
                    <input type="text" name="realName" id="realName"  lay-verify="realName"  placeholder="请输入真实姓名">
                </li>
                <li class="clearfix">
                   <nav class="fl">
                        <label><span class="red">*</span> 密码</label>
                        <input type="password" name="password" id="password" lay-verify="password"  placeholder="请输入密码">
                   </nav>
                    <div class="gary ft14 fr passTips">密码最少为8位，且至少包含大写字母、小写字母，数字、特殊字符(~!@#$%^&*)中的三种</div>
                </li>
              <li class="clearfix">
                    <label><span class="red">*</span> 身份证号</label>
                    <input type="text" name="cardId" id="cardId"  lay-verify="cardId"  placeholder="请输入身份证号">
                </li>
                <li class="clearfix">
                    <label><span class="red">*</span> 性别</label>
                    <div class="layui-col-md3 w80p" style="height: 36px">
                        <select name="sex" id="sex"  lay-verify="sex"  style="width: 30% !important;">
                            <option value="">请选择</option>
                            <option value="1">男</option>
                            <option value="0">女</option>
                        </select>
                    </div>
                </li>
                <li class="clearfix">
                    <label><span class="red">*</span>邮箱</label>
                    <input type="text" name="email" id="email" lay-verify="email"  value=""  placeholder="请输入邮箱">
                </li>
                <li class="clearfix">
                     <label><span class="red">*</span> 学历</label>
                     <div class="layui-col-md3 w80p"  style="height: 36px;">
                         <select name="education" id="education" lay-verify="education" style="width: 30% !important;"  lay-verify="required">
                             <option value="">请选择</option>
                             <#list edulist as vo>
                                 <option value="${vo.badtCode}">${vo.badtName}</option>
                             </#list>
                         </select>
                     </div>
                 </li>
                <li class="clearfix">
                    <label><span class="red">*</span> 常驻地址</label>
                    <div class="layui-col-md3 w40p"  style="height: 36px">
                        <select name="province" id="province" class="ml10" lay-filter="province"  lay-verify="required" style="width:30% !important;">
                            <option value="">请选择</option>
                            <#list provincelist as vo>
                                <option value="${vo.code}">${vo.name}</option>
                            </#list>
                        </select>
                    </div>
                    <div class="layui-col-md3 w40p"  style="height: 36px;">
                        <select name="city" id="city" class="ml10" lay-filter="city"  lay-verify="required" style="width:30% !important;" >
                            <option value="">请选择</option>
                            <#list citylist as vo>
                                <option value="${vo.code}">${vo.name}</option>
                            </#list>
                        </select>
                    </div>
                </li>
                <li class="clearfix">
                    <label><span class="red">*</span> 手机号</label>
                    <input type="text" name="phoneNumber" id="phoneNumber" lay-verify="phoneNumber" placeholder="请输入手机号">
                </li>
                <li class="clearfix">
                    <label>详细地址</label>
                    <input type="text" name="address" id="address" lay-verify="address" placeholder="请输入详细地址">
                </li>
            </ul>
            <div class="regBtn clearfix">
                <a href="/login" class="fl">返回</a>
                <a href="#" class="fr"><button type="button"   lay-filter="register"   lay-submit  class="bluebg white fr bor0">提交</button></a>
            </div>
            <div class="codePassword agreeLogin center">
                <input type="checkbox"  lay-skin="primary"  checked  id="xychecx"  lay-verify="xychecx"   class="fl mt10"   title="同意"/>
                <span >
                    <span><a href="/sys/register/regXy" class="blue">《注册协议》</a></span>和<span><a href="/sys/register/regYs" class="blue">《隐私政策》</a></span>
                </span>
            </div>
        </div>
    </form>
</div>

<!--公用样式JS-->
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/cardUtils.js"></script>
<script>
  var layer;
  var form = layui.form;
  $(function  () {
    layui.use(['form','layer'], function(){
      form.verify({
        username:function(v){
          if(v.trim()==''){
            return "用户名不能为空";
          }
        }
        ,realName:function(v){
          if(v.trim()==''){
            return "真实名称不能为空";
          }
        },password:function(v){
          if(v.trim()==''){
              return '密码不能为空';
          }
          var result = '';
          $.ajax({
              url:'/sys/register/checkpwd',
              data: {pwd: v.trim()},
              type: 'GET',
              cache: false,
              async: false,
              success: function(res){
                  if(!res.flag){
                      result = '密码格式输入有误';
                  }
              }
          })
          return result;
          },cardId:function(v){
              if(v.trim()==''){
                  return '身份证号不能为空';
              }else{
                  var flag = validateIdCard(v.trim());
                  if(flag){
                      return flag;
                  }
              }
          },sex:function(v){
              if(v.trim()==''){
                  return '性别不能为空';
              }
          },email:function(v){
              if(v.trim()==''){
                  return '邮箱不能为空';
              }else{
                  if(v.trim()!=''){
                      var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
                      var flag=  reg.test(v.trim());
                      if(!flag){
                          return '邮箱格式输入有误';
                      }
                  }
              }

          }
          ,education:function(v){
              if(v.trim()==''){
                  return '学历不能为空';
              }
          }
          ,province:function(v){
              if(v.trim()==''){
                  return '省不能为空';
              }
          },city:function(v){
              if(v.trim()==''){
                  return '市不能为空';
              }
          },phoneNumber:function(v){
              if(v.trim()=='') {
                  return '联系方式不能为空';
              }else{
                  if (!v.trim().isMobile() &&  !v.trim().isTel()) {
                      return '请输入正确的手机号码或电话号码\n\n例如:13916752109或0531-3614072';
                  }
              }
          }
      });

        /*--------------------选择省获取市-----------------------------------------*/
        form.on('select(province)', function (data) {
            var code =  data.value;
            if (code == "") {
                return;
            }
            layerAjaxGet('/sys/register/getCity', {"code": code}, '',function(d){
                if (d.flag == true) {
                    $("#city").empty();
                    $("#city").append("<option value=''>选择市</option>");
                    for (var i = 0; i < d.data.length; i++) {
                        $("#city").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                    }
                    form.render('select');
                } else {
                    layer.msg(d.msg, {icon: 2});
                }
            });

        });
            //监听提交
        form.on('submit(register)', function(data){
                var  filed=data.field
                if(filed.province!=''){
                    filed.province =filed.province.replace(",","")
                }
                if(filed.city!=''){
                    filed.city =filed.city.replace(",","")
                }
                var checked=$("#xychecx").prop('checked');
                console.log(checked);
                if(checked!=true){
                    layer.alert("请勾选同意!");
                    return ;
                }
                //供需类型
                if('${gxType}'){
                    filed.gxType = '${gxType}';
                }
                //企业或个人
                if('${personType}'){
                    filed.personType = '${personType}';
                }
                //业务类型
                if('${ywType}'){
                    filed.ywType = '${ywType}';
                }
                console.log(JSON.stringify(data.field));
                layerAjax('/sys/register/register', data.field, '',function(d){
                    if (d.flag == true) {
                        // 跳转到登录成功页面
                        window.location.href= "/sys/register/retosucess";
                    } else {
                        layer.msg(d.msg, {icon: 2});
                    }
                    console.log(d);
                });
                return false;

        });
      form.render();
    });
    layer = layui.layer;
      // 电话校验
      String.prototype.Trim = function () {
          var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);
          return (m == null) ? "" : m[1];
      };
      String.prototype.isMobile = function () {
          return (/^1[3|4|5|7|8|9][0-9]\d{4,8}$/.test(this.Trim()));
      };
      String.prototype.isTel = function () {
          //"兼容格式: 国家代码(2到3位)-区号(2到3位)-电话号码(7到8位)-分机号(3位)"
          //return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
          return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
      };

  })

  if (window != top)
    top.location.href = location.href;
</script>


<!-- 底部结束 -->
</body>
</html>
